﻿package net.wangit.dev.enumeration;

import net.wangit.jdbc.DB;
import net.wangit.util.Checker;
import net.wangit.view.page.PageCache;
import net.wangit.view.unit.UnitCache;

public class EnumerationReferenceUtil {

	private static final String SQL_REFERENCE = "update ELEMENT set r=? where c in (3,6,42,43,44,48,53) and r=?";

	public EnumerationReferenceUtil() {
	}

	public static void update(DB db, String domain, String oldEnumerationId,
			String newEnumerationId) throws Exception {
		if (!Checker.isEmpty(oldEnumerationId)
				&& !oldEnumerationId.equals(newEnumerationId)) {
			db.execute(EnumerationReferenceUtil.SQL_REFERENCE, new String[] {
					newEnumerationId, oldEnumerationId }, new int[] { 2, 2 });
			UnitCache.clearAll(domain);
			PageCache.clearAll(domain);
		}
	}
}
